import request from '@/utils/request'

export interface LoginData {
  username: string
  password: string
}

export interface RegisterData {
  username: string
  password: string
  confirmPassword?: string
}

export interface RegisterResponse {
  message: string
  username: string
}

export const register = (data: RegisterData) => {
  // 确保发送到后端的数据不包含 confirmPassword
  const { confirmPassword, ...registerData } = data
  return request({
    url: 'user/register',
    method: 'post',
    data: registerData
  })
}

export const login = (data: LoginData) => {
  return request({
    url: 'user/login',
    method: 'post',
    data
  })
}

export const userApi = {
  // 获取用户信息
  getUserInfo() {
    return request({
      url: '/user/info',
      method: 'get'
    })
  }
} 